﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;

namespace MINERP.DAL.Statistics
{
    public  class InvoiceDAL
    {
        /// <summary>
        /// wang
        /// </summary>
        /// <param name="whereValue"></param>
        /// <returns></returns>
        public DataSet GetSendGoodsNotice(string whereValue )
        {
            DataSet dsResult = new DataSet();
            Database db = DatabaseFactory.CreateDatabase();


            DbCommand dbCommand = db.GetStoredProcCommand("sp_SendGoodsNotice");
            dbCommand.CommandTimeout = 60;
            db.AddInParameter(dbCommand, "whereSql", DbType.String, whereValue);
         
            try
            {
                dsResult = db.ExecuteDataSet(dbCommand);
            }
            catch (Exception)
            {
                return null;
            }

            return dsResult;
        }


        /// <summary>
        /// Packing List
        /// </summary>
        /// <param name="whereValue"></param>
        /// <returns></returns>
        public DataSet GetPackingList(string whereValue)
        {
            DataSet dsResult = new DataSet();
            Database db = DatabaseFactory.CreateDatabase();


            DbCommand dbCommand = db.GetStoredProcCommand("sp_PackingList");
            dbCommand.CommandTimeout = 60;
            db.AddInParameter(dbCommand, "whereSql", DbType.String, whereValue);

            try
            {
                dsResult = db.ExecuteDataSet(dbCommand);
            }
            catch (Exception)
            {
                return null;
            }

            return dsResult;
        }
        //GetInvoice
        /// <summary>
        /// GetInvoice
        /// </summary>
        /// <param name="whereValue"></param>
        /// <returns></returns>
        public DataSet GetInvoice(string whereValue)
        {
            DataSet dsResult = new DataSet();
            Database db = DatabaseFactory.CreateDatabase();


            DbCommand dbCommand = db.GetStoredProcCommand("sp_INVOICE");
            dbCommand.CommandTimeout = 60;
            db.AddInParameter(dbCommand, "whereSql", DbType.String, whereValue);

            try
            {
                dsResult = db.ExecuteDataSet(dbCommand);
            }
            catch (Exception)
            {
                return null;
            }

            return dsResult;
        }

        public DataSet GetRequestPaper(string whereValue)
        {
            DataSet dsResult = new DataSet();
            Database db = DatabaseFactory.CreateDatabase();


            DbCommand dbCommand = db.GetStoredProcCommand("sp_RequestPaper");
            dbCommand.CommandTimeout = 60;
            db.AddInParameter(dbCommand, "whereSql", DbType.String, whereValue);

            try
            {
                dsResult = db.ExecuteDataSet(dbCommand);
            }
            catch (Exception)
            {
                return null;
            }

            return dsResult;
        }
    }
}
